package cn.hxth.dubbo.customer.controller;

import cn.hxth.api.model.Consumer;
import cn.hxth.api.query.ConsumerQueryObject;
import cn.hxth.api.query.PageResult;
import cn.hxth.api.service.IConsumerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/pages/consumer/")
public class ConsumerController {
    @Resource
    private IConsumerService consumerService ;
    @RequestMapping("findAll")
    public PageResult findAll(ConsumerQueryObject ConsumerQueryObject){
        return this.consumerService.findAll(ConsumerQueryObject) ;
    }
    @RequestMapping("insertConsumer")
    public  boolean insertConsumer(Consumer Consumer){
        return  this.consumerService.insertConsumer(Consumer) ;
    }
    @RequestMapping("updateConsumer")
    public  boolean update(Consumer Consumer){
        return  this.consumerService.updateConsumer(Consumer) ;
    }
    @RequestMapping("removeConsumer")
    public  boolean removeConsumer(Integer cid){
        return  this.consumerService.removeConsumer(cid) ;
    }
    @RequestMapping("getConsumer")
    public  Consumer getConsumer(Integer cid) {
        return  this.consumerService.getConsumer(cid) ;
    }
    @ResponseBody
    @RequestMapping("getConsumerForMq")
    public  Consumer getConsumerForMq(Integer cid) {
        return  this.consumerService.getConsumerForMq(cid) ;
    }
    @RequestMapping("updateTotal")
    // 更新购货单位消费总额(MQ使用)
    public boolean updateTotal(@RequestBody Consumer consumer) {
        boolean flag = this.consumerService.updateTotal(consumer) ;
        return flag ;

    }
}
